$(()=>{
    $("#payOrder").click(function (){
        const orderNumber = $("#orderNoValue").val();
        window.location.href = "/shopping/selectPayType?orderNumber=" + orderNumber;
    });

    $("#cancelOrder").click(function (){
        const orderNumber = $("#orderNoValue").val();
        Swal.fire({
            title: "客官请注意",
            text: "确认要取消订单吗?",
            icon: "warning",iconColor:"#dea32c",
            showCancelButton: true,
            confirmButtonText: '确认',
            cancelButtonText: '取消'
        }).then((flag) =>{
            if (flag.value) {
                $.ajax({
                    url:ctx+"/shopping/cancelOrder",
                    method:"post",
                    data:{
                        orderNumber:orderNumber,
                    },
                    success: function (resp) {
                        if (resp.code === 200) {
                            window.location.reload();
                        } else {
                            Swal.fire({
                                text: resp.msg,
                                icon: "error",iconColor:"#f05b72",
                            });
                        }
                    },
                    error: function () {
                        Swal.fire({
                            text: "操作失败",
                            icon: "error",iconColor:"#f05b72",
                        });
                    }
                });
            }
        });
    });
    $("#queren").click(function (){
        const orderNumber = $("#orderNoValue").val();
        Swal.fire({
            title: "客官请注意",
            text: "是否确认收货?",
            icon: "success",iconColor:"#dea32c",
            showCancelButton: true,
            confirmButtonText: '确认',
            cancelButtonText: '取消'
        }).then((flag) =>{
            if (flag.value) {
                $.ajax({
                    url:ctx+"/shopping/shouhuo",
                    method:"post",
                    data:{
                        orderNumber:orderNumber,
                    },
                    success: function (resp) {
                        if (resp.code === 200) {
                            window.location.reload();
                        } else {
                            Swal.fire({
                                text: resp.msg,
                                icon: "error",iconColor:"#f05b72",
                            });
                        }
                    },
                    error: function () {
                        Swal.fire({
                            text: "操作失败",
                            icon: "error",iconColor:"#f05b72",
                        });
                    }
                });
            }
        });
    })
});